<?php
declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class ChangeColumnTypeDemandTypeInNoteTable extends AbstractMigration
{
    public function up()
    {
        $this->table('note')
            ->changeColumn('demand_type', 'enum', [
                'values' => 'default,feedback,review_feedback,repair_feedback,demand,comment',
                'default' => 'default',
                'comment' => '需求类型 (default 默认,feedback 反馈,review_feedback 审核反馈,repair_feedback 返修反馈,demand 需求,comment评论)'
            ])
            ->addColumn('comment_subject_id', 'integer', [
                'null' => false,
                'default' => 0,
                'limit' => 11,
                'comment' => '评论主体note_id',
            ])
            ->addColumn('comment_floor_note_id', 'integer', [
                'null' => false,
                'default' => 0,
                'limit' => 11,
                'comment' => '评论楼层note_id',
            ])
            ->save();
    }

    public function down()
    {
        $this->table('note')
            ->changeColumn('demand_type', 'enum', ['values' => 'default,feedback,review_feedback,repair_feedback,demand', 'default' => 'default', 'comment' => '需求类型 (default 默认,feedback 反馈,review_feedback 审核反馈,repair_feedback 返修反馈,demand 需求)'])
            ->removeColumn('comment_subject_id')
            ->removeColumn('comment_floor_note_id')
            ->save();
    }
}
